# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models


class Migration(SchemaMigration):

    def forwards(self, orm):
        # Adding model 'Stock'
        db.create_table(u'basic_info_stock', (
            ('code', self.gf('django.db.models.fields.CharField')(max_length=8, primary_key=True)),
            ('short_name', self.gf('django.db.models.fields.CharField')(max_length=20, db_index=True)),
            ('pinyin_name', self.gf('django.db.models.fields.CharField')(max_length=20)),
            ('full_name', self.gf('django.db.models.fields.CharField')(max_length=100, blank=True)),
            ('csrc_industry', self.gf('django.db.models.fields.CharField')(max_length=40)),
            ('csrc_sub_industry', self.gf('django.db.models.fields.CharField')(max_length=20)),
        ))
        db.send_create_signal(u'basic_info', ['Stock'])

        # Adding model 'StockAlias'
        db.create_table(u'basic_info_stockalias', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('stock', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['basic_info.Stock'])),
            ('alias', self.gf('django.db.models.fields.CharField')(max_length=20)),
            ('created_at', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
        ))
        db.send_create_signal(u'basic_info', ['StockAlias'])

        # Adding model 'Industry'
        db.create_table(u'basic_info_industry', (
            ('name', self.gf('django.db.models.fields.CharField')(max_length=40, primary_key=True)),
        ))
        db.send_create_signal(u'basic_info', ['Industry'])

        # Adding model 'StockIndustryMap'
        db.create_table(u'basic_info_stockindustrymap', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('stock', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['basic_info.Stock'])),
            ('industry', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['basic_info.Industry'])),
            ('created_at', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
        ))
        db.send_create_signal(u'basic_info', ['StockIndustryMap'])

        # Adding unique constraint on 'StockIndustryMap', fields ['stock', 'industry']
        db.create_unique(u'basic_info_stockindustrymap', ['stock_id', 'industry_id'])

        # Adding model 'Location'
        db.create_table(u'basic_info_location', (
            ('name', self.gf('django.db.models.fields.CharField')(max_length=40, primary_key=True)),
        ))
        db.send_create_signal(u'basic_info', ['Location'])

        # Adding model 'StockLocationMap'
        db.create_table(u'basic_info_stocklocationmap', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('stock', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['basic_info.Stock'])),
            ('location', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['basic_info.Location'])),
            ('created_at', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
        ))
        db.send_create_signal(u'basic_info', ['StockLocationMap'])

        # Adding unique constraint on 'StockLocationMap', fields ['stock', 'location']
        db.create_unique(u'basic_info_stocklocationmap', ['stock_id', 'location_id'])

        # Adding model 'Concept'
        db.create_table(u'basic_info_concept', (
            ('name', self.gf('django.db.models.fields.CharField')(max_length=100, primary_key=True)),
        ))
        db.send_create_signal(u'basic_info', ['Concept'])

        # Adding model 'StockConceptMap'
        db.create_table(u'basic_info_stockconceptmap', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('stock', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['basic_info.Stock'])),
            ('concept', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['basic_info.Concept'])),
            ('created_at', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
        ))
        db.send_create_signal(u'basic_info', ['StockConceptMap'])

        # Adding unique constraint on 'StockConceptMap', fields ['stock', 'concept']
        db.create_unique(u'basic_info_stockconceptmap', ['stock_id', 'concept_id'])

        # Adding model 'Institute'
        db.create_table(u'basic_info_institute', (
            ('short_name', self.gf('django.db.models.fields.CharField')(max_length=20, primary_key=True)),
            ('full_name', self.gf('django.db.models.fields.CharField')(max_length=100, blank=True)),
        ))
        db.send_create_signal(u'basic_info', ['Institute'])


    def backwards(self, orm):
        # Removing unique constraint on 'StockConceptMap', fields ['stock', 'concept']
        db.delete_unique(u'basic_info_stockconceptmap', ['stock_id', 'concept_id'])

        # Removing unique constraint on 'StockLocationMap', fields ['stock', 'location']
        db.delete_unique(u'basic_info_stocklocationmap', ['stock_id', 'location_id'])

        # Removing unique constraint on 'StockIndustryMap', fields ['stock', 'industry']
        db.delete_unique(u'basic_info_stockindustrymap', ['stock_id', 'industry_id'])

        # Deleting model 'Stock'
        db.delete_table(u'basic_info_stock')

        # Deleting model 'StockAlias'
        db.delete_table(u'basic_info_stockalias')

        # Deleting model 'Industry'
        db.delete_table(u'basic_info_industry')

        # Deleting model 'StockIndustryMap'
        db.delete_table(u'basic_info_stockindustrymap')

        # Deleting model 'Location'
        db.delete_table(u'basic_info_location')

        # Deleting model 'StockLocationMap'
        db.delete_table(u'basic_info_stocklocationmap')

        # Deleting model 'Concept'
        db.delete_table(u'basic_info_concept')

        # Deleting model 'StockConceptMap'
        db.delete_table(u'basic_info_stockconceptmap')

        # Deleting model 'Institute'
        db.delete_table(u'basic_info_institute')


    models = {
        u'basic_info.concept': {
            'Meta': {'object_name': 'Concept'},
            'name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'primary_key': 'True'}),
            'stocks': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['basic_info.Stock']", 'through': u"orm['basic_info.StockConceptMap']", 'symmetrical': 'False'})
        },
        u'basic_info.industry': {
            'Meta': {'object_name': 'Industry'},
            'name': ('django.db.models.fields.CharField', [], {'max_length': '40', 'primary_key': 'True'}),
            'stocks': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['basic_info.Stock']", 'through': u"orm['basic_info.StockIndustryMap']", 'symmetrical': 'False'})
        },
        u'basic_info.institute': {
            'Meta': {'object_name': 'Institute'},
            'full_name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
            'short_name': ('django.db.models.fields.CharField', [], {'max_length': '20', 'primary_key': 'True'})
        },
        u'basic_info.location': {
            'Meta': {'object_name': 'Location'},
            'name': ('django.db.models.fields.CharField', [], {'max_length': '40', 'primary_key': 'True'}),
            'stocks': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['basic_info.Stock']", 'through': u"orm['basic_info.StockLocationMap']", 'symmetrical': 'False'})
        },
        u'basic_info.stock': {
            'Meta': {'object_name': 'Stock'},
            'code': ('django.db.models.fields.CharField', [], {'max_length': '8', 'primary_key': 'True'}),
            'csrc_industry': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
            'csrc_sub_industry': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
            'full_name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
            'pinyin_name': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
            'short_name': ('django.db.models.fields.CharField', [], {'max_length': '20', 'db_index': 'True'})
        },
        u'basic_info.stockalias': {
            'Meta': {'object_name': 'StockAlias'},
            'alias': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
            'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'stock': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['basic_info.Stock']"})
        },
        u'basic_info.stockconceptmap': {
            'Meta': {'unique_together': "(('stock', 'concept'),)", 'object_name': 'StockConceptMap'},
            'concept': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['basic_info.Concept']"}),
            'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'stock': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['basic_info.Stock']"})
        },
        u'basic_info.stockindustrymap': {
            'Meta': {'unique_together': "(('stock', 'industry'),)", 'object_name': 'StockIndustryMap'},
            'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'industry': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['basic_info.Industry']"}),
            'stock': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['basic_info.Stock']"})
        },
        u'basic_info.stocklocationmap': {
            'Meta': {'unique_together': "(('stock', 'location'),)", 'object_name': 'StockLocationMap'},
            'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'location': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['basic_info.Location']"}),
            'stock': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['basic_info.Stock']"})
        }
    }

    complete_apps = ['basic_info']